package utility;



import javax.persistence.Entity;


import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;



import gqms_tool.LoginUser;

public class HibernateUtility {
	
	public static void salvaUtente(LoginUser u){
		Session session=null;
		
		try
		{
			SessionFactory sf;
			Configuration cfg = new Configuration();
			cfg.configure();
			sf = cfg.buildSessionFactory();
			
			
			
			
			session = sf.openSession();
			Transaction tx = session.beginTransaction();
			
			
			session.save(u);
			
			tx.commit();
			session.close();
			
		
	}catch(Exception e){
		e.printStackTrace();
	}
		finally{
		
			session.close();
		}
		
	}
	

}
